/**
 * Author: Eato
 * Description: Display table status in restaurant in terms of order which existed.
 */
package GoldenEagle;

import java.util.ArrayList;
import java.util.Arrays;

public class Table {
	private int maxTable;
	private boolean[] status;
	/**
	 * Table's Constructor
	 * Get the maximum number of table from the text file for initialize
	 * call the "chkStatus" function
	 * @param arrOrder 
	 * Pass the Menu System's Order Array to this class
	 */
	public Table(ArrayList<Order> arrOrder) {
		maxTable = Integer.parseInt(DataProvider.getData("Max Table"));
		status = new boolean[maxTable];
		chkStatus(arrOrder);
	}
	/**
	 * Check the table's status by using the Order Array List
	 * @param arr 
	 * Pass the constructor's array list to this function
	 * for this function to check the order whether it is existing or not
	 */
	private void chkStatus(ArrayList<Order> arr) {

		Arrays.fill(status, Boolean.FALSE);
		for (int i = 0; i < arr.size(); i++) {
			Order o = arr.get(i);
			status[o.getTable() - 1] = true;
		}
	}
	/**
	 * Display the Table status screen
	 */
	public void display() {
		int tableNo = 0;
		for (int i = 0; i < maxTable; i++) {
			tableNo = i + 1;
			if (status[i] != true) {
				System.out.println("Table " + tableNo + " : Available");
			} else {
				System.out.println("Table " + tableNo + " : In-use");
			}

		}
	}

}
